#include "p24F04KA200.h"
#include "uart.h"
#include "util.h"

char *itoa(unsigned i, char *buf) {
    /* Size-1 */
    unsigned size = 0, j = i;
    while (j >= 10) {
        j /= 10;
        size++;
    }

    buf[size + 1] = 0;

    j = i;
    while (j >= 10) {
        buf[size] = '0' + j % 10;
        j /= 10;
        size--;
    }
    buf[size] = '0' + j % 10;

    return buf;
}

void sendVT100Cmd(char *cmd) {
    write(ASCII_escape_char);
    writeStr(cmd);
}